package com.megvii.corelib.util;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

/**
 * Created by linyue on 16/3/9.
 */
public class AlertDialogUtil
{
    public static void showMessage(Context context, String message, final AlertDialogListener listener)
    {
        AlertDialog.Builder builder = new AlertDialog.Builder(context,
                AlertDialog.THEME_HOLO_LIGHT);
        builder.setTitle("提示");
        builder.setMessage(message);
        builder.setPositiveButton("确定", new DialogInterface.OnClickListener()
        {
            @Override
            public void onClick(DialogInterface dialog, int which)
            {
                if (listener != null)
                {
                    listener.onAlertDialogClose();
                }
            }
        });
        AlertDialog alertDialog = builder.create();
        alertDialog.show();
        alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener()
        {
            @Override
            public void onCancel(DialogInterface dialog)
            {
                if (listener != null)
                {
                    listener.onAlertDialogClose();
                }
            }
        });
    }

    public static interface AlertDialogListener
    {
        public void onAlertDialogClose();
    }
}
